﻿class WheelModule {

	//속성정의
	private var instance:MovieClip;
	private var dragClip:MovieClip;

	//생성자 함수 초기화
	public function WheelModule(_instance:MovieClip, _dragClip:MovieClip) {

		this.instance = _instance;
		this.dragClip = _dragClip;
		this.wheelInit();

	}

	private function wheelInit():Void {

		var instance = this.instance;
		var dragClip = this.dragClip;

		var someListener:Object = new Object();

		someListener.onMouseWheel = function(delta) {

			startWheel(delta,instance,dragClip);
		};

		Mouse.addListener(someListener);

		//=========================================================================휠의 모션 종류에 사용자 정의 구문

		function startWheel(_delta, _instance, _dragClip):Void {


			var instance:MovieClip = _instance;
			var dragClip:MovieClip = _dragClip;

			this.instance.wheelCheck = true;

			if (instance.wheelCheck == true) {

				if (_delta<0) {
					//trace("delte="+"음수이다");
					instance.dragIt.dragControl();
					instance.dragIt.dragMotionControl();
					if (dragClip._y<instance.dragIt.dragClipInitY+instance.dragIt.dragBnBgLength-dragClip._height) {
						dragClip.targetYpos = dragClip._y+dragClip._height;
					} else if (dragClip._y>=instance.dragIt.dragClipInitY+instance.dragIt.dragBnBgLength-dragClip._height) {
						dragClip.targetYpos = Stage.height-dragClip._height;
					}

				}
				if (_delta>0) {
					//trace("delte="+"양수이다");
					instance.dragIt.dragControl();
					instance.dragIt.dragMotionControl();
					if (dragClip._y>instance.dragIt.dragClipInitY) {
						dragClip.targetYpos = dragClip._y-dragClip._height;
					} else if (dragClip._y<=instance.dragIt.dragClipInitY) {
						dragClip.targetYpos = instance.dragIt.dragClipInitY;

					}
				}
			}
		}

	}

}